/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package kimo.persistence.entities;

import java.io.Serializable;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author a381u296
 */
@Entity
@Table(name = "municipality")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Municipality.findAll", query = "SELECT m FROM Municipality m"),
    @NamedQuery(name = "Municipality.findByMunicipalityId", query = "SELECT m FROM Municipality m WHERE m.municipalityId = :municipalityId"),
    @NamedQuery(name = "Municipality.findByMunicipalityName", query = "SELECT m FROM Municipality m WHERE m.municipalityName = :municipalityName")})
public class Municipality implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "municipality_id")
    private String municipalityId;
    @Basic(optional = false)
    @Column(name = "municipality_name")
    private String municipalityName;
    @JoinColumn(name = "municipality_prefecture_id", referencedColumnName = "prefecture_id")
    @ManyToOne(optional = false)
    private Prefecture municipalityPrefectureId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "producerRuralMunicipalityId")
    private List<Producer> producerList;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "producerMunicipalityId")
    private List<Producer> producerList1;

    public Municipality() {
    }

    public Municipality(String municipalityId) {
        this.municipalityId = municipalityId;
    }

    public Municipality(String municipalityId, String municipalityName) {
        this.municipalityId = municipalityId;
        this.municipalityName = municipalityName;
    }

    public String getMunicipalityId() {
        return municipalityId;
    }

    public void setMunicipalityId(String municipalityId) {
        this.municipalityId = municipalityId;
    }

    public String getMunicipalityName() {
        return municipalityName;
    }

    public void setMunicipalityName(String municipalityName) {
        this.municipalityName = municipalityName;
    }

    public Prefecture getMunicipalityPrefectureId() {
        return municipalityPrefectureId;
    }

    public void setMunicipalityPrefectureId(Prefecture municipalityPrefectureId) {
        this.municipalityPrefectureId = municipalityPrefectureId;
    }

    @XmlTransient
    public List<Producer> getProducerList() {
        return producerList;
    }

    public void setProducerList(List<Producer> producerList) {
        this.producerList = producerList;
    }

    @XmlTransient
    public List<Producer> getProducerList1() {
        return producerList1;
    }

    public void setProducerList1(List<Producer> producerList1) {
        this.producerList1 = producerList1;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (municipalityId != null ? municipalityId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Municipality)) {
            return false;
        }
        Municipality other = (Municipality) object;
        if ((this.municipalityId == null && other.municipalityId != null) || (this.municipalityId != null && !this.municipalityId.equals(other.municipalityId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return municipalityName;
    }
    
}
